import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class VideoPlayerPage extends StatefulWidget {
  const VideoPlayerPage({super.key});

  @override
  State<VideoPlayerPage> createState() => _VideoPlayerPageState();
}

class _VideoPlayerPageState extends State<VideoPlayerPage> {
  late VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.networkUrl(Uri.parse(
        'https://img.metatube.pro/mh/video/3e631d2e739c6a7d1da4bf2e8f672d58.mp4'))
      ..initialize().then((_) {
        setState(() {});
        _controller.play();
        _controller.setLooping(true);
      });
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(children: [
      _controller.value.isInitialized ? SizedBox.expand(
        child: FittedBox(
          fit: BoxFit.cover,
          child: SizedBox(
            width: _controller.value.size.width,
            height: _controller.value.size.height,
            child: VideoPlayer(_controller),
          ),
        ),
      )
          : const Center(child: CircularProgressIndicator()
      ),
        Scaffold(
            backgroundColor: Colors.transparent,
            appBar: AppBar(
                iconTheme: const IconThemeData(
                  color: Colors.white,
                ),
                title: const Text("video player"),
                titleTextStyle: const TextStyle(color: Colors.white),
                backgroundColor: Colors.transparent),
            body: const Center(child: Text("11111", style: TextStyle(color: Colors.white, fontSize: 24))))
      ]
    );
  }
}
